/**
 * 
 */
package org.whereiswally.job.findurl;

import org.jppf.server.protocol.JPPFTask;
import org.whereiswally.net.url.URLManager;
import org.whereiswally.net.url.generation.URLGenerator;

/**
 * @author LGIAVEDO
 * 
 */
public class FindURLJob extends JPPFTask {

    private URLManager urlManager;
    private URLGenerator urlGenerator;

    public FindURLJob(URLManager urlManager, URLGenerator urlGenerator) {
	super();
	this.urlManager = urlManager;
	this.urlGenerator = urlGenerator;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Runnable#run()
     */
    @Override
    public void run() {
	while (urlGenerator.hasNext()) {
	    if (urlManager.checkURL(urlGenerator.next())) {
		// Existe, debo lanzar un evento
		System.out.println("ENCONTRADO -->"
			+ urlGenerator.getLastGenerated());
		// beep. jajaj
		java.awt.Toolkit.getDefaultToolkit().beep();
		fireNotification(urlGenerator.getLastGenerated());
	    }
	}

    }

}
